#include "object.h"


Object::Object()
{
    m_BodyDef.type = b2_dynamicBody;
    m_BodyDef.position.Set(0, 0);
    m_BodyDef.userData = this;
}

void Object::AddToWorld( b2World& _world )
{
    m_Body = _world.CreateBody(&m_BodyDef);
    b2CircleShape cs;
    cs.m_radius = 10;
    m_Body->CreateFixture(&cs, 100);
    m_Body->SetAwake(true);
}

void Object::Draw( QPainter& _painter )
{
    _painter.drawImage(QPointF(GetX(), GetY()), *m_Image.get());
}

float Object::GetX() const
{
    return m_Body->GetPosition().x;
}

float Object::GetY() const
{
    return m_Body->GetPosition().y;
}

void Object::SetImage( const QString& _imageFileName )
{
    m_Image.reset(new QImage(_imageFileName));
}
